package net.dipper.tankwar.editor.helper;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Image;
import java.io.IOException;

import net.dipper.tankwar.core.config.TowerItem;

import wnb.util.io.ImageManager;

public class TowerRenderer implements ObjectRenderer {
	private TowerItem item;
	
	public TowerRenderer(TowerItem item){
		this.item = item;
	}

	@Override
	public void renderSelection(Graphics2D g2, int x, int y, int gW, int gH) {
		try{
			double radius = item.getRadius();
			int W = (int) (gW * radius * 2);
			int H = (int)(gH * radius * 2);
			Image img = ImageManager.getImage(item.getImg());
			g2.drawImage(img, x * gW, y * gH, gW, gH, null);
			g2.setColor(Color.RED);
			g2.drawArc(x * gW - (W - gW) / 2, y * gH - (H - gH) / 2, W, H, 0, 360);
		}catch(IOException ex){
			ex.printStackTrace();
		}
		
	}

}
